HAL MDF migration: List of applicable concepts

This section provides information about the HAL MDF applicable architecture concepts.

In HAL1, a single driver handles both MDF and ADF peripherals. In HAL2, the MDF driver has been split into two separate drivers MDF and ADF. This separation enhances maintainability and modularity.

All these MDF concepts are applicable also for ADF. Simply replace MDF with ADF to get the corresponding ADF concepts. For more details, see : MDF specific concept

Concepts for MDF

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate init and config functions:

  • HAL_MDF_Init(): initializes the handle and links it to a MDF instance.

  • HAL_MDF_SetConfig(): configures the processing clock divider.

each block of the MDF have its own configuration function example:

  • HAL_MDF_SITF_SetConfig(): configures the serial interface.

  • HAL_MDF_BSMX_SetConfig(): configures the bitstream matrix.

  • …

Removal and conversion of init structure to configuration structure

The structure MDF_InitTypeDef is no longer available. it has been Split into multiple configuration structures by block example:

  • hal_mdf_serial_interface_config_t: configures the serial interface.

  • hal_mdf_digital_filter_config_t: configures the digital filter, etc.

Renaming of the handle structure

The handle structure has been renamed to hal_mdf_handle_t.

Remove MspInit and MspDeInit callbacks

HAL_MDF_MspInit() and HAL_MDF_MspDeInit() are no longer available. They have to be replaced by a user-defined sequence to initialize and configure the MDF.

Unitary configuration APIs

New APIs are available to set and get MDF features.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro has been replaced by a new function HAL_MDF_SetDMA() to link a MDF HAL handle to a DMA HAL handle.

Introduction of HAL user data set/get APIs

Two functions to Set/Get User Data are available:

  • HAL_MDF_SetUserData()

  • HAL_MDF_GetUserData()

Individual callback registration APIs replace global register and unregister functions

The registration of callbacks for MDF events is managed by dedicated functions. Each function is responsible for registering callback functions for specific MDF events.

Revised and optimized HAL state machine

In HAL2, the HAL MDF and ADF driver provides several state machines, one per block.

Revised and optimized HAL API status returns

The HAL MDF functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

New APIs for filtering optional asynchronous process interrupts

New APIs are provided in the MDF to filter and manage asynchronous process interrupts :

  • HAL_MDF_DFLT_StartAcq_IT_Opt()

  • HAL_MDF_DFLT_StartAcq_DMA_Opt()

Replaced TypeDef suffix with _t in type names

All TypeDef parts in MDF have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Adding const keyword to non-modifiable pointers ensures that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Add HAL PPP Services for Drivers with Handle to Retrieve Corresponding Peripheral Clock Frequency.

HAL MDF provides new API to retrieve clock frequency: HAL_MDF_GetClockFreq().

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including MDF instances) have been converted into enumerated types (enums) at the HAL level. This improves code readability, maintainability, and type safety.

Optimize HAL PPP IRQ Handlers by Reordering Processes and Error Management Statements to Prioritize Critical Interrupts

In HAL2, the implementation of HAL_MDF_IRQHandler() API has been improved for performance éto prioritize the handling of critical interrupts.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL MDF functions start with HAL_MDF and all HAL MDF enums and structs start with hal_mdf.

MDF specific concept

Concept

Consideration

Split MDF driver into two drivers MDF and ADF

In HAL1, a single driver handles both MDF and ADF peripherals. In HAL2, the MDF driver has been split into two separate drivers MDF and ADF. This separation enhances maintainability and modularity.

Adopt a tree topology for MDF modeling in HAL2

From a hardware perspective, the MDF peripheral can be viewed as:

  • A common Clock Generation block (CCG)

  • Multiple MDF_Filter_x blocks

MDF block diagram

HAL1: Instantiate by digital filter

  • Each MDF_Filter_x is considered as an instance.

  • The MDF mainly contains the global clock generation configuration for all its sub-blocks (MDF_Filter_x, SITFX, BSMx, SCDx, etc.).

  • When configuring a HAL_Filter_x instance, the HAL1 driver determines which peripheral instance (ADF or MDF) to configure, then configures the common Clock Generation block and the required blocks like SITFX, BSMx, , SCDx, etc.

HAL2: Instantiate by MDF/ADF peripheral

  • The HAL instance corresponds to the exact peripheral instance.

  • The global configuration configures the MDF clock generation.

  • The MDF filters are considered as sub-instances with their corresponding configuration functions.

  • Additionally, the SITFX, BSMx and other blocks are considered as sub-blocks with their own configuration and starting functions.